<%@ page language="java" contentType="text/html;charset=UTF-8"%>
<%@ include file="/static/include/taglib.jsp"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE html>
<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>后台管理--用户编辑</title>
    <link href="${ctxStatic}/ligeruilib/ligerUI/skins/Aqua/css/ligerui-all.css" rel="stylesheet" type="text/css">
    <link href="${ctxStatic}/layui/css/layui.css" rel="stylesheet" />
    <link href="${ctxStatic}/css/kpiuitanchu.css" rel="stylesheet" />
    <script src="${ctxStatic}/js/jquery-1.8.3.min.js?v=2.0" type="text/javascript"></script>
    <script src="${ctxStatic}/layui/layui.all.js"  type="text/javascript"></script>
    <script src="${ctxStatic}/ligeruilib/ligerUI/js/core/base.js" type="text/javascript"></script>
    <script src="${ctxStatic}/ligeruilib/ligerUI/js/plugins/ligerTree.js" type="text/javascript"></script>
    <script src="${ctxStatic}/ligeruilib/ligerUI/js/plugins/ligerComboBox.js" type="text/javascript"></script>

    <script>
        $(function(){
            var orgdata=null;
            var groupid=$("#hidgroup").val();
            $.ajax({
                url:"../common/get_org_list?orgtype=1",
                type:"get",
                success:function(data){
                    //orgdata=data;
                    orgdata=eval('('+data+')');
                    if(groupid!=''&&groupid!=null){
                        var newData = new Array();
                        for (i = 0; i < orgdata.length; i++)
                        {
                            if (orgdata[i].orgid == groupid)
                            {
                                newData.push(orgdata[i]);
                            }
                        }
                        liger.get("group").setData(newData);
                        liger.get("group").setValue(groupid);
                    }

                }
            })

            var szdw=$("#hidszdw").val();
            if(szdw!=''&&szdw!=null){
                $("#szdw").ligerComboBox({
                    valueField : 'orgid',
                    textField : 'orgname',
                    selectBoxWidth : 278,
                    selectBoxHeight:200,
                    treeLeafOnly:true,
                    valueFieldID:"hid",
                    value: $("#hidszdw").val(),
                    initIsTriggerEvent: false,
                    tree: {url : '../common/get_org_list?orgtype=0',
                        checkbox: false,
                        nodeWidth:177,
                        ajaxType: 'get',
                        idFieldName: 'orgid',
                        textFieldName:"orgname",
                        idField:"orgid",
                        parentIDField:"orgparentid"
                    },
                    onSelected : function(orgid, orgname) {// id为空值，name为选择的值
                        $("#hidszdw").val(orgid);

                        var newData = new Array();
                        for (i = 0; i < orgdata.length; i++)
                        {
                            if (orgdata[i].orgparentid == orgid)
                            {
                                newData.push(orgdata[i]);
                            }
                        }
                        liger.get("group").setData(newData);

                    },
                    width : 280
                });
            }
            else{
                $("#szdw").ligerComboBox({
                    valueField : 'orgid',
                    textField : 'orgname',
                    selectBoxWidth : 278,
                    selectBoxHeight:200,
                    treeLeafOnly:true,
                    valueFieldID:"hid",
                    initIsTriggerEvent: false,
                    tree: {url : '../common/get_org_list?orgtype=0',
                        checkbox: false,
                        nodeWidth:177,
                        ajaxType: 'get',
                        idFieldName: 'orgid',
                        textFieldName:"orgname",
                        idField:"orgid",
                        parentIDField:"orgparentid"
                    },
                    onSelected : function(orgid, orgname) {// id为空值，name为选择的值
                        $("#hidszdw").val(orgid);

                        var newData = new Array();
                        for (i = 0; i < orgdata.length; i++)
                        {
                            if (orgdata[i].orgparentid == orgid)
                            {
                                newData.push(orgdata[i]);
                            }
                        }
                        liger.get("group").setData(newData);

                    },
                    width : 280
                });
            }




            var rsgxszdw=$("#hidrsgxszdw").val();
            if(rsgxszdw!=''&&rsgxszdw!=null){
                $("#rsgxszdw").ligerComboBox({
                    valueField : 'orgid',
                    textField : 'orgname',
                    selectBoxWidth : 278,
                    selectBoxHeight:200,
                    treeLeafOnly:true,
                    valueFieldID:"hid",
                    value: $("#hidrsgxszdw").val(),
                    initIsTriggerEvent: false,
                    tree: {url : '../common/get_org_list?orgtype=0',
                        checkbox: false,
                        nodeWidth:177,
                        ajaxType: 'get',
                        idFieldName: 'orgid',
                        textFieldName:"orgname",
                        idField:"orgid",
                        parentIDField:"orgparentid"
                    },
                    onSelected : function(orgid, orgname) {// id为空值，name为选择的值
                        $("#hidrsgxszdw").val(orgid);
                    },
                    width : 280
                });
            }
            else{
                $("#rsgxszdw").ligerComboBox({
                    valueField : 'orgid',
                    textField : 'orgname',
                    selectBoxWidth : 278,
                    selectBoxHeight:200,
                    treeLeafOnly:true,
                    valueFieldID:"hid",
                    initIsTriggerEvent: false,
                    tree: {url : '../common/get_org_list?orgtype=0',
                        checkbox: false,
                        nodeWidth:177,
                        ajaxType: 'get',
                        idFieldName: 'orgid',
                        textFieldName:"orgname",
                        idField:"orgid",
                        parentIDField:"orgparentid"
                    },
                    onSelected : function(orgid, orgname) {// id为空值，name为选择的值
                        $("#hidrsgxszdw").val(orgid);


                    },
                    width : 280
                });
            }




            $("#group").ligerComboBox({
                data: null,
                valueField: 'orgid',
                textField: 'orgname',
                selectBoxWidth : 278,
                selectBoxHeight:200,
                autocomplete: true,
                width: 280,
                onSelected: function(orgid, orgname){//id为空值，name为选择的值
                    $("#hidgroup").val(orgid);
                },
            })


        })

        function InitGroup(orgid){
            $("#group").ligerComboBox(
                {
                    url: '../common/get_org_list_byorgid?orgid='+orgid,
                    valueField: 'orgid',
                    textField: 'orgname',
                    selectBoxWidth : 280,
                    selectBoxHeight:200,
                    autocomplete: true,
                    keySupport: true,
                    valueFieldID:"hid",
                    onSelected: function(orgid, orgname){//id为空值，name为选择的值
                        $("#hidgroup").val(orgid);
                    },
                    width: 280
                }
            );
        }


        function InitGroupTree(orgid){
            $("#group").ligerComboBox({
                valueField : 'orgid',
                textField : 'orgname',
                selectBoxWidth : 280,
                selectBoxHeight:200,
                treeLeafOnly:false,
                valueFieldID:"hidorgtype",

                tree: {url : '../common/get_org_list?orgtype=1',
                    checkbox: false,
                    nodeWidth:167,
                    ajaxType: 'get',
                    idFieldName: 'orgid',
                    textFieldName:"orgname",
                    idField:"orgid",
                    parentIDField:"orgparentid",
                    selectable:function(data){
                        if(data.orgtype==0){
                            return false;
                        }
                        else{
                            return true;
                        }
                    },
                    onBeforeSelect:function(data){
                        if(data.data.orgtype==0){
                            return false;
                        }
                        else{
                            return true;
                        }
                    }
                },
                onSelected : function(orgid, orgname) {// id为空值，name为选择的值
                    $("#hidgroup").val(orgid);
                },
                //onBeforeSelect:function(orgid,orgname){
                // return false;
                //},
                width : 280
            });
        }

    </script>
</head>
<body>
<div class="tanchucontent">
    <form class="layui-form" id="formedit" name="formedit" action="add_user" method="post" target="d41d8cd98f00b204e9800998ecf8427e">
        <iframe name="d41d8cd98f00b204e9800998ecf8427e" src="about:blank" style="display:none;"></iframe>

        <table style="width:95%">
            <tr>
                <td class="td_right" style="width:130px">用户名：</td>
                <td>
                    <input type="text"  name="realname" lay-verify="required" autocomplete="off"  class="layui-input"  >


                </td>

            </tr>



        </table>

        <input type="hidden" name="userid" id="hiduserid" value="${entity.userid}">

    </form>
</div>
<script>
    layui.use(['form','element','laydate'], function(){
        var form = layui.form;
        var element = layui.element;
        var laydate = layui.laydate;

        form.render();


        //监听提交
        /*form.on('submit(demo1)', function(data){
          layer.alert(JSON.stringify(data.field), {
                   title: '最终的提交信息'
                 })
                 return false;
          }); */
    });

    function CloseDialog(result,msg){
        top.frames["iframe"].vUser.addresult(result,msg);
    }
</script>
</body>
</html>